package com.ruoyi.water.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.water.domain.IdCorrespond;
import com.ruoyi.water.mapper.IdCorrespondMapper;
import com.ruoyi.water.service.IIdCorrespondService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 表具ID与资产编号对应关系Service实现
 */
@Service
public class IdCorrespondServiceImpl extends ServiceImpl<IdCorrespondMapper, IdCorrespond> implements IIdCorrespondService {

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int batchSave(List<IdCorrespond> correspondList) {
        // 使用MyBatis-Plus的批量插入方法
        boolean isSuccess = saveBatch(correspondList);
        // 如果成功，返回插入的数量（即列表大小），失败返回0
        return isSuccess ? correspondList.size() : 0;
    }
}
